import java.io.*;
import java.io.BufferedReader; 
import java.io.InputStreamReader;

class Shell 
{
	public void ejecutar(String[]args) 
	{
	String command = "";
	String linea = "";
	try
	{
		while(true)
		{
			Runtime cmd = Runtime.getRuntime();
			StringBuilder mensaje = new StringBuilder();
			command = "";

			BufferedReader lectura = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Cliente >>> ");
			command = lectura.readLine();


			if(command.equals("exit"))
			{
				System.out.println("Adios...");
				Process proceso = cmd.exec(command);
				break;
			}

			Process proceso = cmd.exec(command);
			InputStreamReader entrada = new InputStreamReader(proceso.getInputStream());
			BufferedReader buffer = new BufferedReader(entrada);

			while( (linea = buffer.readLine()) != null )
			{                 
               			mensaje.append(linea+"\n"); 
            		} 
            		buffer.close();
			
			System.out.println(mensaje);
		}
	}
	catch(Exception ex){System.out.println(ex);}
	}
}